#ifndef EXCEPTIONS_HPP
#define EXCEPTIONS_HPP

#include <iostream>
#include <exception>
#include <sstream>

class ImageNotFoundExceptions : public std::exception
{
public:

  ImageNotFoundExceptions(const std::string &imageName) :
    _imageName(imageName)
  {
  }

  virtual const char *what() const throw()
    {
      std::string msg = "Unabled to load " + _imageName;
      return msg.c_str();
    }

  virtual ~ImageNotFoundExceptions() throw() {}

private:
  const std::string _imageName;
};

class FontNotFoundExceptions : public std::exception
{
 public:

  FontNotFoundExceptions(const std::string &fontName) :
    _fontName(fontName)
  {
  }

  virtual const char *what() const throw()
    {
      std::string msg = "Unabled to load " + _fontName;
      return msg.c_str();
    }

  virtual ~FontNotFoundExceptions() throw() {}

private:
  const std::string _fontName;

};

class LibraryInteralError : public std::exception
{
public:

  LibraryInteralError(const std::string &libName, const std::string &errorMsg) :
    _errorMsg(errorMsg) ,
    _libName(libName)
  {
  }

  virtual const char *what() const throw()
    {
      std::string msg = _libName + " Error  : " + _errorMsg;
      return msg.c_str();
    }

  virtual ~LibraryInteralError() throw() {}

private:
    const std::string _errorMsg;
    const std::string _libName;
};

class BadWindowProportions : public std::exception
{
public:
  BadWindowProportions(int x, int y)
    {
      std::stringstream ss;
      ss << x << '*' << y;
      _coordonate = ss.str();
    }

  virtual const char *what() const throw()
    {
      std::string msg = _coordonate + " are bad width/height :\n \t-width and weight must be a multiple of 16\n\t-max : 1920*1080\n\t-min : 512*480";
      return msg.c_str();
    }

  virtual ~BadWindowProportions() throw() {}
private:
  std::string _coordonate;

};


class LoadGraphicLibrairie : public std::exception
{
public:
  LoadGraphicLibrairie(const std::string &errorMsg, const std::string &path) :
    _errorMsg(errorMsg),
    _path(path)
  {}

  virtual const char *what() const throw()
    {
      std::string msg("Unabled to load graphics librairy " + _path + " : " + _errorMsg);
      return msg.c_str();
    }

  virtual ~LoadGraphicLibrairie() throw() {}

private:
  const std::string _errorMsg;
  const std::string _path;
};

class LoadFunctionException : public std::exception
{
public:
  LoadFunctionException(const std::string &functionName, const std::string &path) :
    _functionName(functionName),
    _path(path)
    {
    }

  virtual const char *what() const throw()
    {
      std::string msg("Unabled to load fonction " + _functionName + " in " + _path);
      return msg.c_str();
    }

  virtual ~LoadFunctionException() throw() {}

private:
  const std::string _functionName;
  const std::string _path;
};

#endif /* end of include guard: EXCEPTIONS_HPP */
